package service

import (
	"bms/dao"
	"bms/model"
	"log"
)

func GetUser(username, password, usertype, phone, email string) *model.User {
	user := dao.GetUser(username, password, usertype, phone, email)
	return user
}

func CheckUser(username string) (*model.User, error) {
	user, _ := dao.CheckUser(username)
	return user, nil
}

func SaveUser(username, password, phone, email string) error {
	err := dao.SaveUser(username, password, phone, email)
	if err != nil {
		return err
	}
	return nil
}

func GetAllUser() ([]*model.User, error) {
	users, err := dao.GetAllUser()
	if err != nil {
		return nil, err
	}
	return users, nil
}

func QueryUser(userId int64) bool {
	b := dao.QueryUser(userId)
	if b {
		return true
	}
	return false
}
func ReviseUser(user *model.User) error {
	err := dao.ReviseUser(user)
	if err != nil {
		log.Println(err)
		return err
	}
	return nil
}

func DeleteUser(userId int64) error {
	err := dao.DeleteUser(userId)
	if err != nil {
		return err
	}
	return nil
}
